#!/bin/sh

set -e

function check_root() {
    set +e
    echo -e "start check root"
    if [[ $(id -u) -ne 0 ]]; then
        echo "current user is not root"
        exit 0
    else
        echo "current user is root"
        set -e
        return 0
    fi
}

function file_format_check() {
    set +e
    echo -e "check file format"
    bash -c "dos2unix --version"
    if [[ $? -ne 0 ]]; then
        bash -c "apt-get -f -y install dos2unix"
    fi
    set -e
    bash -c "find . -type f | grep -v '/\.' | xargs dos2unix"
}
